package com.zbkj.front.controller.assistant;


import com.zbkj.common.model.assistant.AssistantQuestion;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.result.CommonResult;
import com.zbkj.front.controller.assistant.service.AssistantQuestionService;
import com.zbkj.service.assistant.model.request.AssistantQuestionSearchRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 常用问题表 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/front/assistant/question")
@Api(tags = "客服-常用问题") //配合swagger使用

public class AssistantQuestionController {

    @Autowired
    private AssistantQuestionService assistantQuestionService;


    @ApiOperation(value = "分页列表") //配合swagger使用
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<AssistantQuestion>> getList(@Validated AssistantQuestionSearchRequest request) {
        CommonPage<AssistantQuestion> assistantQuestionCommonPage = CommonPage.restPage(assistantQuestionService.getPage(request));
        return CommonResult.success(assistantQuestionCommonPage);
    }

//    /**
//     * 新增常用问题表
//     * @param assistantQuestionRequest 新增参数
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "新增")
//    @RequestMapping(value = "/save", method = RequestMethod.POST)
//    public CommonResult<String> save(@RequestBody @Validated AssistantQuestionRequest assistantQuestionRequest) {
//        AssistantQuestion assistantQuestion = new AssistantQuestion();
//        BeanUtils.copyProperties(assistantQuestionRequest, assistantQuestion);
//
//        if(assistantQuestionService.save(assistantQuestion)) {
//            return CommonResult.success();
//        } else {
//            return CommonResult.failed();
//        }
//    }
//
//    /**
//     * 删除常用问题表
//     * @param id Integer
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "删除")
//    @RequestMapping(value = "/delete", method = RequestMethod.GET)
//    public CommonResult<String> delete(@RequestParam(value = "id") Integer id) {
//        if(assistantQuestionService.removeById(id)) {
//            return CommonResult.success();
//        } else {
//            return CommonResult.failed();
//        }
//    }
//
//    /**
//     * 修改常用问题表
//     * @param id integer id
//     * @param assistantQuestionRequest 修改参数
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "修改")
//    @RequestMapping(value = "/update", method = RequestMethod.POST)
//    public CommonResult<String> update(@RequestParam Integer id, @RequestBody @Validated AssistantQuestionRequest assistantQuestionRequest) {
//        AssistantQuestion assistantQuestion = new AssistantQuestion();
//        BeanUtils.copyProperties(assistantQuestionRequest, assistantQuestion);
//        assistantQuestion.setId(id);
//
//        if(assistantQuestionService.updateById(assistantQuestion)) {
//            return CommonResult.success();
//        } else {
//            return CommonResult.failed();
//        }
//    }
//
//    /**
//     * 查询常用问题表信息
//     * @param id Integer
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "详情")
//    @RequestMapping(value = "/info", method = RequestMethod.GET)
//    public CommonResult<AssistantQuestion> info(@RequestParam(value = "id") Integer id) {
//        AssistantQuestion assistantQuestion = assistantQuestionService.getById(id);
//        return CommonResult.success(assistantQuestion);
//    }
}



